package test.app.audit;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;


@Entity
@Table(name = "AbstractAuditRecord")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(columnDefinition="AUDIT_RECORD_TYPE",discriminatorType=DiscriminatorType.STRING)
public abstract class AbstractAuditRecord implements Serializable {
	
	private static final long serialVersionUID = 4595182090632073304L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
			
	@Column(name = "operationType")
	@Enumerated(EnumType.STRING)
	private OperationType operationType;
	
	@Column(name = "operationKey")
	private String operationKey;
	
	@Column(name = "operationDate")
	private Date operationDate;
	
	@Column(name = "message")
	private String message;
	
	@Column(name = "username")
	private String username;
	
	//hibernate 
	@Column(name = "AUDIT_RECORD_TYPE")
	@Enumerated(EnumType.STRING)
	private RecordType auditRecordType;
	
	
	@Column(name = "IPUsuario")
	private String ipUsuario;
		
	public Date getOperationDate() {
		return operationDate;
	}
	public void setOperationDate(Date date) {
		this.operationDate = date;
	}
	
		
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	
	public String getOperationKey() {
		return operationKey;
	}
	public void setOperationKey(String operationKey) {
		this.operationKey = operationKey;
	}
		
	public OperationType getOperationType() {
		return operationType;
	}
	
	public void setOperationType(OperationType operationType) {
		this.operationType = operationType;
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	public RecordType getAuditRecordType() {
		return auditRecordType;
	}
	
	public void setAuditRecordType(RecordType auditRecordType) {
		this.auditRecordType = auditRecordType;
	}
	
	public String getIpUsuario() {
		return ipUsuario;
	}
	public void setIpUsuario(String ipUsuario) {
		this.ipUsuario = ipUsuario;
	}
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE).
				append("operationType",operationType).
				append("operationKey",operationKey).
				append("operationDate",operationDate).
				append("message",message).
				append("username",username).toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder().append(operationType).
				append(operationDate).
				append(operationKey).
				append(message).
				append(username).
				toHashCode();
	}
	
	public boolean equals(Object o) {
		if(o instanceof AbstractAuditRecord) {	}
		
		return false;
	}
	
	


}
